package com.huawei;

import java.util.Scanner;

/**
 * Description: HJ35 蛇形矩阵
 *
 * @author weiruibai.vendor
 * Date: 2022/10/11 14:29
 */
public class HJ35 {

    public static void main(String[] args) {
        Scanner in = new Scanner(System.in);
        Integer N = in.nextInt();
        if (N <= 0) {
            return;
        }
        int[][] ans = new int[N][N];
        ans[0][0] = 1;
        // ans前一个值 从1,2,....开始
        int preNum = 2;
        for (int i = 1; i < N; i++) {
            ans[i][0] = preNum++;
            int row = i - 1;
            for (int j = 1; j <= i && row >= 0; j++) {
                // 斜对角
                ans[row--][j] = preNum++;
            }
        }
        for (int i = 0; i < N; i++) {
            for (int j = 0; j < N - i; j++) {
                System.out.print(ans[i][j] + " ");
            }
            System.out.println("");
        }
    }

    /**
     *
     */
    private static void test1() {
        Scanner in = new Scanner(System.in);
        Integer N = in.nextInt();
        if (N <= 0) {
            return;
        }
        int rowBase = 1;
        int colBase = 1;
        /**
         i=0 rowBase=1,colBase=2
         1 3 6 10 15
         i=1 rowBase=2,colBase=3
         2 5 9 14
         i=2 rowBase=4,colBase=4
         4 8 13
         i=3 rowBase=7,colBase=5
         7 12
         i=4 rowBase=11,colBase=6
         7
         */
        for (int i = 0; i < N; i++) {
            // 每行的开始数此后每列都在次基础上+row
            rowBase = rowBase + i;
            // 每列开始间距 此后每列间距都+1
            colBase = colBase + 1;

            int baseVal = rowBase;
            int baseC = colBase;
            for (int j = 0; j < N - i; j++) {
                System.out.print(baseVal + " ");
                baseVal = baseVal + baseC + j;
            }
            System.out.println("");
        }
    }
}
